package com.lcredu.springbootusersys.controller;

import com.lcredu.springbootusersys.exception.AccessException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

/**
 * @author 黎长容
 * @date 2025-08-16 19:52
 */
@Controller
public class MyErrorController {

    //制造405
    @PostMapping("/err")
    public void create405() {
        System.out.println("OK");
    }

    //制造500
    @GetMapping("/err2")
    public void error02() {
        int i = 5 / 0;
    }


    @GetMapping("/err3")
    public String error03(String name) {
        if (!"lcr".equals(name)) {
            throw new AccessException("用户无权限");
        }

//        return "manage";
        return "redirect:/manage.html";
    }

}
